<template>
  <div>
    <h2>子组件</h2>
    <p>{{ props.msg }}</p>
    <button @click="sonEvent">子组件按钮</button>
    <p>{{ sonData }}</p>
  </div>
</template>

<script setup>
import { defineProps, ref, defineEmits } from 'vue'
const sonData = ref('子组件数据')
const props = defineProps({
  msg: {
    type: String,
    default: '默认值'
  }
})
// console.log(props)

const emit = defineEmits(['click'])
const sonEvent = () => {
  emit('click', sonData.value)
}
</script>

<style lang="scss" scoped></style>
